<template>
    <div class="modal fade" id="signFail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content" >
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">签约失败</h4>
                </div>
                <div class="modal-body">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label for="" class="col-sm-4 control-label"><i class="required">*</i>签约失败原因：</label>
                            <div class="col-sm-8">
                                <textarea rows="5" class="form-control" v-model="signFailReason" placeholder="签约失败原因"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn checkedBtn"  @click="save">确定</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        //接收父组件的绑定值
        props: ["signFailCusPre"],
        data(){
            return{
                signFailReason:''
            }
        },
        methods:{
            save:function(){
                var _self = this;
                var body = {}
                if(!_self.signFailReason){
                    layer.msg("请填写签约失败原因");
                    return
                }

                var params = {
                    id : _self.signFailCusPre.id,
                    remark : _self.signFailReason,
                    confirmStatus : 4
                }
                body.params = params;
                var url = _self.utilHelper.apiUrl+'/api/changeCPConfirm';
                _self.$http.post(url,body).then((response) =>{
                    var res = response.body.resData;
                    if(res.result == '1') {
                        layer.msg("变更成功");
                        $('#signFail').modal('hide');
                        _self.$emit('saveSignFail')
                    }else {
                        layer.msg(res.resultMsg);
                    }
                },(response)=>{
                    layer.msg("系统异常");
                });
            }
        }
    }
</script>

<style scoped>

</style>